package com.lh.lock;

public class MySynchronized {

    public static void main(String[] args) {

        Object lock = new Object();

        //m1(lock);

        m2();

    }

    private static synchronized void m2() {
        new Thread(()->{
            System.out.println("实例同步方法!");
        }).start();
    }

    private static void m1(Object lock) {
        new Thread(()->{

            synchronized (lock){
                System.out.println("同步代码块!");
            }
        }).start();
    }
}
